package models;

import java.util.Date;
import java.util.List;

import play.data.validation.Required;
import siena.Id;
import siena.Index;
import siena.Query;

public class IdeaUnit extends AbstractUnit {
	public String content;
	public String description;
	public Date otherDate;
	
	@Index("idearequest_index")
	@Required public IdeaRequest ideaRequest;
	
	static Query<IdeaUnit> all() {
		return all(IdeaUnit.class);
	}
	
	public static IdeaUnit findById(Long id) {
		return all().filter("id", id).get();
	}
	
	public static List<IdeaUnit> findByAuthor(User author) {
		return all().filter("author", author).fetch();
	}
	
	public static List<IdeaUnit> findByIdeaRequest(IdeaUnit request) {
		return all().filter("activity", request).fetch();
	}
}
